package org.frog.sgs.card;

import org.frog.sgs.card.basic.Basic;
import org.frog.sgs.character.Character;

/**
 * @author duanxiangqi
 * @date 2012-10-15
 */
public abstract class AbstractCard implements Card {

	private static final long serialVersionUID = 7483263935505188298L;

	private Character character;

	private int id;

	private String name;

	private String desc;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public Character getCharacter() {
		return character;
	}

	public void setCharacter(Character character) {
		this.character = character;
	}

	public String getViewName() {
		if (this instanceof Basic) {
			Basic basic = (Basic) this;
			String value = "";
			switch (basic.getSuit().getValue()) {
			case 1:
				value = "黑桃";
				break;
			case 2:
				value = "红桃";
				break;
			case 3:
				value = "草花";
				break;
			case 4:
				value = "方块";
				break;
			default:
				break;
			}
			return getName() + "(" + getId() + "," + value + basic.getPoints() + ")";
		} else {
			return getName() + "(" + getId() + ")";
		}
	}

	public String toString() {
		//		StringBuilder builder = new StringBuilder();
		//		builder.append("[id:").append(getId());
		//		builder.append(", name:").append(getName());
		//		if (this instanceof Basic) {
		//			builder.append(", suit:").append(((Basic) this).getSuit().getValue());
		//			builder.append(", points:").append(((Basic) this).getPoints());
		//		}
		//		builder.append(", class:").append(getClass().getSimpleName());
		//		// builder.append(", character:").append(getCharacter());
		//		// builder.append(", desc:").append(getDesc());
		//		builder.append("]");
		//		return builder.toString();
		return getViewName();
	}
}
